package com.ruoyi.web.enums;

import java.util.HashMap;
import java.util.Map;

public enum InsectTypeEnum {

    //1 始见预警 2 日高峰 3 月高峰
    ONE(1, "一类害虫"),
    TWO(2,"二类害虫"),
    OTHER(3,"其他害虫"),
    ;

    private final int code;
    private final String describe;

    InsectTypeEnum(int code, String describe){
        this.code = code;
        this.describe = describe;
    }

    public Integer getValue() {
        return this.code;
    }

    public String getDescription() {
        return this.describe;
    }

    //根据code查询枚举
    public static InsectTypeEnum getByCode(int code){
        InsectTypeEnum[] enums = InsectTypeEnum.values();
        for( InsectTypeEnum codeEnum : enums){
            if(codeEnum.getValue() == code){
                return codeEnum;
            }
        }

        return null;
    }

    static Map<String,String> map = new HashMap<>();

    static {
        for (InsectTypeEnum value : InsectTypeEnum.values()) {
            map.put(value.name(),value.getDescription());
        }
    }

    /**
     * @desc  得到枚举映射的MAP
     * @author fwx 2023/10/17 16:37
     **/
    public static Map<String,String> getDescMap(){
        return map;
    }

}
